#!/usr/bin/perl -wc

package RFCMail::Util::Callback;

# An object implementation of a callback. More useful than it sounds.

use strict;
use base qw(Exporter);

our @EXPORT_OK = qw(callback);


sub new {
    my $class = shift;
    my $self = shift;
    if (not ref($self)) {
	my $self = [$self, shift];
    }
    return (bless $self, $class);
}


sub callback {
    my $self = shift;
    if (ref($self) eq 'ARRAY') {
	my ($obj, $meth) = @$self;
	$obj->$meth(@_);
    }
    else {
	$self->(@_);
    }
}


sub go { goto &callback }


1;
